package agent.simple.agentmain;

import com.sun.tools.attach.VirtualMachine;

public class AttachTest {

    public static void main(String[] args) {
        try {
            // 注意点!! Agent JAR loaded but agent failed to initialize
            // app.jar启动后，如果先进行了一次attach， 后面在修改 agent.jar 的代码, 新代码不生效
            // 必须 app.jar 重启

            VirtualMachine vm = VirtualMachine.attach("21811");
//            vm.loadAgent("F:\\Workspace\\MyAgent\\target\\myAgent-1.0.jar","param");
            vm.loadAgent("/Users/cyril/workspace/my-projects/java-agent-demo/simple-agentmain-agent/target/simple-agentmain-agent-1.0-SNAPSHOT.jar","param");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}